/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.jsecurity.samples.sprhib.party;

/**
 * Created by IntelliJ IDEA. User: Les Date: Sep 4, 2006 Time: 7:29:33 PM To change this template
 * use File | Settings | File Templates.
 */
public enum Gender {

    MALE("M", "gender.male"),

    FEMALE("F", "gender.female");

    private String initial;
    private String i18nCode = null;

    private Gender(String initial, String i18nCode) {
        this.initial = initial;
        this.i18nCode = i18nCode;
    }

    public String getName() {
        return name();
    }

    public String getInitial() {
        return initial;
    }

    public String getI18nCode() {
        return i18nCode;
    }

    public String toInitial() {
        return getInitial();
    }

    public static Gender fromInitial(String initial) {
        for (Gender gender : values()) {
            if (gender.getInitial().equals(initial)) {
                return gender;
            }
        }

        throw new IllegalArgumentException("Argument not understood.  Need valid initial that matches those " +
                "defined in the " + Gender.class.getName() + " enum");
    }

}

